package com.xh.audit.vo.webform;

import com.mybatisflex.core.query.QueryWrapper;
import com.xh.audit.entity.Law;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.Date;

import static com.xh.audit.entity.table.LawTableDef.LAW;


@Data
@EqualsAndHashCode(callSuper = true)
public class LawQuery extends PageParams<Law> {
    private String lawReleaseNumber;
    private String lawName;
    private Integer lawType;
    private Integer effectFlag;

    private Date lawReleaseDateS;
    private Date lawReleaseDateE;

    private Date lawImplementationDateS;
    private Date lawImplementationDateE;


    public QueryWrapper queryWrapperBuild() {
        QueryWrapper queryWrapper = QueryWrapper.create()

                .and(LAW.LAW_RELEASE_NUMBER.eq(lawReleaseNumber))
                .and(LAW.LAW_TYPE.eq(lawType))
                .and(LAW.EFFECT_FLAG.eq(effectFlag))
                .and(LAW.LAW_NAME.likeLeft(lawName))

                .and(LAW.LAW_RELEASE_DATE.ge(lawReleaseDateS))
                .and(LAW.LAW_RELEASE_DATE.le(lawReleaseDateE))

                .and(LAW.LAW_IMPLEMENTATION_DATE.ge(lawImplementationDateS))
                .and(LAW.LAW_IMPLEMENTATION_DATE.le(lawImplementationDateE));
        return queryWrapper;
    }
}
